<?php

/**
 *  检测是否登陆
 */
function check_login() {
    $controller = think\Request::instance()->controller();
    $action = think\Request::instance()->action();
    $host = $_SERVER['HTTP_HOST'];
    $openid = cookie("_openid");
    if (!$openid) {
        $url = url("Login/index@$host", ['_controller' => $controller, '_action' => $action]);
        header("Location:{$url}");
        die;;
    }

    return $openid;
}